﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime;
using System.Text;
using System.Threading.Tasks;

namespace MathGraphics
{
    public struct Vector2F
    {
        public float X { get; set; }
        public float Y { get; set; }

        public double Mod
        {
            get
            {
                return Math.Sqrt(X * X + Y * Y);
            }
        }

        public Vector2F(float x , float y)
        {
            X = x;
            Y = y;
        }

        public static implicit operator Vector2F(Vector2 v)
        {
            return new Vector2F(v.X, v.Y);
        }

        public override bool Equals(object obj)
        {
            return ((Vector2F)obj) == this;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public static Vector2F operator +(Vector2F left, Vector2F right)
        {
            return new Vector2F(left.X + right.X, left.Y + right.Y);
        }

        public static Vector2F operator -(Vector2F left, Vector2F right)
        {
            return new Vector2F(left.X - right.X, left.Y - right.Y);
        }

        public static bool operator ==(Vector2F left, Vector2F right)
        {
            return left.X == right.X && left.Y == right.Y;
        }

        [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
        public static bool operator !=(Vector2F left, Vector2F right)
        {
            return !(left == right);
        }
    }
}
